﻿package com.badibadi.activity;

import java.io.Serializable;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

import org.json.JSONException;
import org.json.JSONObject;

import android.annotation.SuppressLint;
import android.app.AlertDialog;
import android.app.AlertDialog.Builder;
import android.app.ProgressDialog;
import android.content.Intent;
import android.location.Location;
import android.os.Bundle;
import android.os.Handler;
import android.os.Message;
import android.support.v4.app.Fragment;
import android.support.v4.app.FragmentManager;
import android.support.v4.app.FragmentTransaction;
import android.util.Log;
import android.view.LayoutInflater;
import android.view.View;
import android.view.View.OnClickListener;
import android.view.ViewGroup;
import android.widget.AdapterView;
import android.widget.AdapterView.OnItemClickListener;
import android.widget.BaseAdapter;
import android.widget.Button;
import android.widget.GridView;
import android.widget.ImageView;
import android.widget.RelativeLayout;
import android.widget.TabHost;
import android.widget.TabHost.OnTabChangeListener;
import android.widget.TextView;

import com.amap.api.location.AMapLocation;
import com.amap.api.location.AMapLocationListener;
import com.amap.api.location.LocationManagerProxy;
import com.amap.api.location.LocationProviderProxy;
import com.amap.api.location.core.GeoPoint;
import com.amap.api.maps2d.AMap;
import com.amap.api.maps2d.AMap.InfoWindowAdapter;
import com.amap.api.maps2d.AMap.OnInfoWindowClickListener;
import com.amap.api.maps2d.AMap.OnMapClickListener;
import com.amap.api.maps2d.AMap.OnMarkerClickListener;
import com.amap.api.maps2d.CameraUpdateFactory;
import com.amap.api.maps2d.LocationSource;
import com.amap.api.maps2d.MapView;
import com.amap.api.maps2d.model.BitmapDescriptorFactory;
import com.amap.api.maps2d.model.LatLng;
import com.amap.api.maps2d.model.Marker;
import com.amap.api.maps2d.model.MarkerOptions;
import com.amap.api.services.core.LatLonPoint;
import com.amap.api.services.geocoder.GeocodeAddress;
import com.amap.api.services.geocoder.GeocodeQuery;
import com.amap.api.services.geocoder.GeocodeResult;
import com.amap.api.services.geocoder.GeocodeSearch;
import com.amap.api.services.geocoder.GeocodeSearch.OnGeocodeSearchListener;
import com.amap.api.services.geocoder.RegeocodeQuery;
import com.amap.api.services.geocoder.RegeocodeResult;
import com.badibadi.infos.AllPhoto_Model;
import com.badibadi.infos.BrowseAllPhoto_Model;
import com.badibadi.infos.Club_InfoSeachModel;
import com.badibadi.infos.ImageAttribute;
import com.badibadi.infos.PhotoIdToInfoModel;
import com.badibadi.infos.Results;
import com.badibadi.maputil.AMapUtil;
import com.badibadi.maputil.ToastUtil;
import com.badibadi.mytools.AMapUtils;
import com.badibadi.mytools.BitmapHelp;
import com.badibadi.mytools.Constants;
import com.badibadi.mytools.JSONUtils;
import com.badibadi.mytools.MyThreadTool;
import com.badibadi.mytools.TabHostUtils;
import com.badibadi.mytools.Utils;
import com.badibadi.uniclubber.R;
import com.libjph.util.StringUtil;
//import com.lidroid.xutils.util.LogUtils;
import com.miloisbadboy.view.PullToRefreshView;
import com.miloisbadboy.view.PullToRefreshView.OnFooterRefreshListener;
import com.miloisbadboy.view.PullToRefreshView.OnHeaderRefreshListener;
import com.nostra13.universalimageloader.core.DisplayImageOptions;
import com.nostra13.universalimageloader.core.ImageLoader;
import com.nostra13.universalimageloader.core.display.RoundedBitmapDisplayer;

/**
 * v4包 photoid 这里已经被标记 up_pictures_uping_img intent PicturePreviewActivity
 * up_pictures_settings onStart up_pictures_uping_img up_pictures_settings
 * 
 * @author Administrator startActivity picture up_pictures_uping_img UpPictures
 *         up_pictures_uping_img OnRe
 */
public class UpPicturesActivity extends BaseActivity {
	private static final String TAG = "UpPicturesActivity";
	private static final int Resh = 80;
	private TabHost mTabHost;
	private FragmentManager manager;
	private UpPicturesFragment0 uFragment0;
	private UpPicturesFragment1 uFragment1;
	private RelativeLayout up_pictures_uping_img;
	private TextView up_pictures_tital;
	private String type_upimg = null;
	private String photo_name;
	private String showType;
	private String cid = null;
	private int add_in;
	private String photoid;
	private Results resultsss;
	private ImageAttribute imageAttribute;
	private String activity_id;
	// DisplayImageOptions options;

	private String isJoin;// 是否加入了俱乐部（0没有 1加入了）(个人的为null)
	private String is_apply;// 是否需要申请表 （个人的为null）
	private Results resultsdd;
	private AlertDialog builder;
	// 根据相册id查找相册名，俱乐部id，种类等等。。。。
	PhotoIdToInfoModel photoIdToInfoModel;

	Club_InfoSeachModel club_InfoSeachModel;
	// private String is_mePic;// 是否是自己的图片(用于判定权限，在图片预览界面中需要判定是否由编辑该图片信息)
	private String is_upload;// 是否有权限上传图片
	private Handler mHandler = new Handler() {
		@Override
		public void handleMessage(Message msg) {
			switch (msg.what) {
			case 1:
				// System.out.println("发送成功:" +
				// msg.getData().getString("tital"));
				try {
					up_pictures_tital.setText(photo_name
							+ msg.getData().getString("tital"));
				} catch (Exception e) {
					// TODO: handle exception
				}
				break;
			// case 3000:
			// imageAttribute = (ImageAttribute) msg.getData()
			// .getSerializable("img_info");
			// imgInformationSave();
			// break;
			case 2:

				try {
					Utils.ExitPrgress(UpPicturesActivity.this);
					Utils.showMessage(UpPicturesActivity.this, getResources()
							.getString(R.string.l_net_error));
				} catch (Exception e) {
					// TODO: handle exception
				}

				break;
			case 3:
				Utils.ExitPrgress(UpPicturesActivity.this);
				try {
					Utils.showMessage(UpPicturesActivity.this, getResources()
							.getString(R.string.l_xb147));
					mHandler.sendEmptyMessageDelayed(10, 700);
				} catch (Exception e) {
					// TODO: handle exception
				}

				break;
			case 10:
				try {
					uFragment0.gengxin();
				} catch (Exception e) {
					// TODO: handle exception
				}

				break;
			case 4:
				Utils.ExitPrgress(UpPicturesActivity.this);
				try {
					Utils.showMessage(UpPicturesActivity.this, getResources()
							.getString(R.string.l_xa10));
				} catch (Exception e) {
					// TODO: handle exception
				}

				break;

			case 5:
				try {
					Utils.ExitPrgress(UpPicturesActivity.this);
					Utils.showMessage(UpPicturesActivity.this,
							resultsdd.getRetmsg());
				} catch (Exception e) {
					// TODO: handle exception
				}

				break;
			case 6:
				try {
					Utils.ExitPrgress(UpPicturesActivity.this);
					Utils.showMessage(UpPicturesActivity.this, getResources()
							.getString(R.string.l_xa10));
				} catch (Exception e) {
					// TODO: handle exception
				}

				break;
			case 7:
				try {
					Utils.ExitPrgress(UpPicturesActivity.this);
					Utils.showMessage(UpPicturesActivity.this, getResources()
							.getString(R.string.l_net_error));
				} catch (Exception e) {
					// TODO: handle exception
				}
				break;
			case 8:// 这是根据相册id查找后成功返回
				try {
					// Log.v(TAG, "photo_name=" + photo_name + "type_upimg="
					// + type_upimg + "showType=" + showType + "cid="
					// + cid);
					Utils.ExitPrgress(UpPicturesActivity.this);
					// photoIdToInfoModel.getPhotoCid();
					photo_name = photoIdToInfoModel.getPhotoName();
					type_upimg = photoIdToInfoModel.getUploadType();
					showType = "img";
					is_upload = photoIdToInfoModel.getIs_upload();
					cid = photoIdToInfoModel.getPhotoCid();
					// Log.v(TAG, "photo_name=" + photo_name + "type_upimg="
					// + type_upimg + "showType=" + showType + "cid="
					// + cid);
					if (cid.equals("0") || cid == null) {
						cid = null;
						isJoin = null;
						is_apply = null;
						init();
						// Log.v(TAG, "1 photo_name=" + photo_name +
						// "type_upimg="
						// + type_upimg + "showType=" + showType + "cid="
						// + cid);
					} else {
						// Log.v(TAG, "cid=" + cid);
						// 根据俱乐部id，判断该用户是否加入俱乐部，该俱乐部是否需要申请表
						// commonality/userInClubs
						// Log.v(TAG, "2 photo_name=" + photo_name +
						// "type_upimg="
						// + type_upimg + "showType=" + showType + "cid="
						// + cid);
						userInClubs(cid);
					}
					// showType = getIntent().getStringExtra("showType");
					// cid = getIntent().getStringExtra("cid");
				} catch (Exception e) {
					// TODO: handle exception
				}

				break;
			case 9:// 这是根据俱乐部id查找
				try {
					Utils.ExitPrgress(UpPicturesActivity.this);
					// private String isJoin;// 是否加入了俱乐部（0没有 1加入了）(个人的为null)
					// private String is_apply;// 是否需要申请表 （个人的为null）
					if (club_InfoSeachModel != null) {

						is_apply = club_InfoSeachModel.getIs_apply();

						if (club_InfoSeachModel.getRole().equals("0")) {
							isJoin = "0";
						} else {
							isJoin = "1";
						}
						init();
					}

				} catch (Exception e) {
					// TODO: handle exception
				}
				break;
			default:
				break;
			}
		}
	};

	@Override
	protected void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		goToTheTitle();
		setContentView(R.layout.up_pictures);
		// is_mePic = getIntent().getStringExtra("is_mePic");
		photoid = getIntent().getStringExtra("photoid");
		initTabHost();
		// options = new DisplayImageOptions.Builder()
		// .showStubImage(R.drawable.ic_stub)
		// .showImageForEmptyUri(R.drawable.noimage)
		// .showImageOnFail(R.drawable.noimage).cacheInMemory()
		// .cacheOnDisc().displayer(new RoundedBitmapDisplayer(0)).build();
		photoIdToInfo(photoid);
		Constants.is_shuaxin = false;

		// isJoin = getIntent().getStringExtra("isJoin");
		// is_apply = getIntent().getStringExtra("is_apply");
		// init();

	}// up_pictures_layout

	private void initTabHost() {
		// TODO Auto-generated method stub
		mTabHost = (TabHost) findViewById(R.id.up_pictures_tabhost);
		mTabHost.setup();
		mTabHost.addTab(mTabHost
				.newTabSpec("up_pictures one")
				.setIndicator(getResources().getString(R.string.picture),
						getResources().getDrawable(R.drawable.ic_launcher))
				.setContent(R.id.tab1));
		mTabHost.addTab(mTabHost
				.newTabSpec("up_pictures two")
				.setIndicator(getResources().getString(R.string.Icon),
						getResources().getDrawable(R.drawable.ic_launcher))
				.setContent(R.id.tab2));
		TabHostUtils.SetTabHost(this, mTabHost);
		mTabHost.setOnTabChangedListener(new OnTabChangeListener() {

			@Override
			public void onTabChanged(String tabId) {
				FragmentTransaction transaction = manager.beginTransaction();
				switch (mTabHost.getCurrentTab()) {
				case 0:

					if (add_in != 0) {
						uFragment0 = new UpPicturesFragment0();
						transaction
								.replace(R.id.up_pictures_layout, uFragment0);
						transaction.commit();
						add_in = 0;
					}
					break;
				case 1:
					if (add_in != 1) {
						uFragment1 = new UpPicturesFragment1();
						transaction
								.replace(R.id.up_pictures_layout, uFragment1);
						transaction.commit();
						add_in = 1;
					}
					break;
				default:
					break;
				}
			}
		});
	}

	/**
	 * 根据相册ID，查出该相册的相册名，如果是个人相册，判断访客是否可编辑，若为俱乐部相册，判断访客是否可编辑
	 */
	public void photoIdToInfo(final String photoId) {
		MyThreadTool.fixedThreadPool.execute(new Runnable() {

			@Override
			public void run() {
				// TODO Auto-generated method stub
				MyThreadTool.fixedThreadPool.execute(new Runnable() {
					@Override
					public void run() {
						Map<String, Object> map = new HashMap<String, Object>();
						map.put("uid", Utils.getUid(UpPicturesActivity.this));
						map.put("photoId", photoId);
						String content = null;

						content = Utils.sendRequest(map, Constants.BadiUrl_1
								+ "commonality/photoIdToInfo");
						// Log.v(TAG, "根据相册id找信息" + content);
						if (content != null) {
							Results results = Utils.checkResult_NNN(
									UpPicturesActivity.this, content);

							// Log.v(TAG, "根据相册id找信息" + results.getRetmsg());

							if (results != null
									&& !results.getRetmsg().equals("null")) {

								try {
									if (results.isRet() == true) {
										photoIdToInfoModel = JSONUtils.getEntityByJsonString(
												results.getRetmsg(),
												PhotoIdToInfoModel.class);
										mHandler.sendEmptyMessage(8);
									} else {
										mHandler.sendEmptyMessage(2);
									}

								} catch (Exception e) {
									// TODO Auto-generated catch block
									e.printStackTrace();
								}

							} else {

								mHandler.sendEmptyMessage(2);
							}
						} else {

							mHandler.sendEmptyMessage(2);
						}
					}
				});
			}
		});
	}

	/**
	 * 根据俱乐部id，判断该用户是否加入俱乐部，该俱乐部是否需要申请表和申请表内容
	 * 
	 * @param $uid
	 *            ---登录用户ID
	 * @param $cid
	 *            ---俱乐部ID
	 * @param
	 */
	public void userInClubs(final String cid) {

		MyThreadTool.fixedThreadPool.execute(new Runnable() {
			@Override
			public void run() {
				Map<String, Object> map = new HashMap<String, Object>();
				map.put("uid", Utils.getUid(UpPicturesActivity.this));
				map.put("cid", cid);
				String content = null;

				content = Utils.sendRequest(map, Constants.BadiUrl_1
						+ "commonality/userInClubs");
				// Log.v(TAG, "根据俱乐部id找信息" + content);
				if (content != null) {
					Results results = Utils.checkResult_NNN(
							UpPicturesActivity.this, content);

					// Log.v(TAG, "根据俱乐部id找信息" + results.getRetmsg());

					if (results != null && !results.getRetmsg().equals("null")) {

						try {
							if (results.isRet() == true) {
								club_InfoSeachModel = JSONUtils
										.getEntityByJsonString(
												results.getRetmsg(),
												Club_InfoSeachModel.class);
								mHandler.sendEmptyMessage(9);
							} else {
								mHandler.sendEmptyMessage(2);
							}

						} catch (Exception e) {
							// TODO Auto-generated catch block
							e.printStackTrace();
						}

					} else {

						mHandler.sendEmptyMessage(2);
					}
				} else {

					mHandler.sendEmptyMessage(2);
				}

			}
		});
	}

	@Override
	protected void onStart() {
		super.onStart();
		Constants.num_up_img_handler = mHandler;
		try {
			if (Constants.is_shuaxin) {
				Constants.is_shuaxin = false;
				// if (photoid == null)
				// photoid = getIntent().getStringExtra("photoid");
				photoIdToInfo(photoid);
			}
			// init();
		} catch (Exception e) {
		}
		// Log.v(TAG, "onStart()");
		// if (Constants.is_shuaxin == true) {
		// Constants.is_shuaxin = false;
		// if (photoid == null)
		// photoid = getIntent().getStringExtra("photoid");
		// photoIdToInfo(photoid);
		// }

	}

	@Override
	protected void onRestart() {
		// TODO Auto-generated method stub
		super.onRestart();
		// Log.v(TAG, "onRestart()");
		// try {
		// if (Constants.is_shuaxin) {
		// Constants.is_shuaxin
		// if (photoid == null)
		// photoid = getIntent().getStringExtra("photoid");
		// photoIdToInfo(photoid);
		//
		// }
		// // init();
		// } catch (Exception e) {
		// }

	}

	private void init() {
		// try {
		//
		// photo_name = getIntent().getStringExtra("photo_name");
		// type_upimg = getIntent().getStringExtra("type_upimg");
		// showType = getIntent().getStringExtra("showType");
		// cid = getIntent().getStringExtra("cid");
		// } catch (Exception e) {
		// e.printStackTrace();
		// }

		// photoid = "4";
		// photo_name = "测试名字";
		manager = getSupportFragmentManager();
		FragmentTransaction transaction = manager.beginTransaction();
		up_pictures_tital = (TextView) findViewById(R.id.up_pictures_tital);
		up_pictures_tital.setText(photo_name);
		this.findViewById(R.id.up_pictures_back).setOnClickListener(
				new OnClickListener() {

					@Override
					public void onClick(View arg0) {
						UpPicturesActivity.this.finish();
					}
				});
		// 设置
		this.findViewById(R.id.up_pictures_settings).setOnClickListener(
				new OnClickListener() {

					@Override
					public void onClick(View arg0) {
						// sdlaf;
						if (!Utils.getUid(UpPicturesActivity.this).equals("")) {
							if (photoIdToInfoModel != null) {
								if (photoIdToInfoModel.getPhotoCid()
										.equals("0")
										|| ("" + photoIdToInfoModel
												.getPhotoCid()).equals("null")) {
									Intent intent = new Intent(
											UpPicturesActivity.this,
											Edit_Poly_Activity.class);
									intent.putExtra("photoid", photoid);
									startActivity(intent);
								} else {
									Intent intent = new Intent(
											UpPicturesActivity.this,
											ClubSpaceModifyTheClubPolyActivity.class);
									intent.putExtra("photoid", photoid);
									intent.putExtra("cid",
											photoIdToInfoModel.getPhotoCid());
									intent.putExtra("photoIdToInfoModel",
											photoIdToInfoModel);
									startActivity(intent);
								}
							}

							// Intent intent = new
							// Intent(UpPicturesActivity.this,
							// Edit_Poly_Activity.class);
							// Intent intent = new
							// Intent(UpPicturesActivity.this,
							// ClubSpaceModifyTheClubPolyActivity.class);
							// // 需要传入相册id
							// intent.putExtra("photoid", photoid);
							// startActivity(intent);
						} else {
							Utils.showMessage(UpPicturesActivity.this,
									getResources().getString(R.string.l_xb10));
						}
					}
				});
		up_pictures_uping_img = (RelativeLayout) findViewById(R.id.up_pictures_uping_img);
		up_pictures_uping_img.setOnClickListener(new OnClickListener() {

			@Override
			public void onClick(View arg0) {
				// Intent intent = new Intent(UpPicturesActivity.this,
				// ImgFileListActivity.class);
				// intent.putExtra("panduan", "set");
				// intent.putExtra("club", cid);
				// intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
				// startActivity(intent);

				// if(isJoin.equals("1") && isJoin!=null)
				// {
				// Intent intent = new Intent(UpPicturesActivity.this,
				// SelectPicts_Activity.class);
				// intent.putExtra("panduan", "set");
				// if (cid != null) {
				// intent.putExtra("club", cid);
				// }
				// startActivity(intent);
				// }else
				// {
				// builder = new Builder(UpPicturesActivity.this)
				// .setView(Back_Buju()).show();

				// }
				if (!Utils.getUid(UpPicturesActivity.this).equals("")) {
					if (isJoin == null) {

						if (is_upload.equals("1")) {
							Intent intent = new Intent(UpPicturesActivity.this,
									SelectPicts_Activity.class);
							intent.putExtra("panduan", "set");
							intent.putExtra("photoid", photoid);
							// if (cid != null) {
							// intent.putExtra("club", cid);
							// }
							startActivityForResult(intent, 5);
						} else {
							Utils.showMessage(UpPicturesActivity.this,
									getResources().getString(R.string.l_xb121));
						}

					} else if (isJoin.equals("1")) {
						if (is_upload.equals("1")) {
							Intent intent = new Intent(UpPicturesActivity.this,
									SelectPicts_Activity.class);
							intent.putExtra("panduan", "set");
							intent.putExtra("photoid", photoid);
							if (cid != null) {
								intent.putExtra("club", cid);
							}
							startActivityForResult(intent, 5);
						} else {
							Utils.showMessage(UpPicturesActivity.this,
									getResources().getString(R.string.l_xb121));
						}

					} else {
						builder = new Builder(UpPicturesActivity.this).setView(
								Back_Buju()).show();
					}
				} else {
					Utils.showMessage(UpPicturesActivity.this, getResources()
							.getString(R.string.l_xb10));
				}
			}
		});

		uFragment0 = new UpPicturesFragment0();
		uFragment1 = new UpPicturesFragment1();
		transaction.replace(R.id.up_pictures_layout, uFragment0);
		transaction.commit();
		add_in = 0;

	}

	@Override
	protected void onActivityResult(int requestCode, int resultCode, Intent data) {
		// TODO Auto-generated method stub
		super.onActivityResult(requestCode, resultCode, data);
		// Log.v("sss1", "传出1:" + requestCode + " " + "回传1:" + resultCode);
		if (requestCode == 5 && resultCode == 5) {
			imageAttribute = (ImageAttribute) data
					.getSerializableExtra("img_info");
			imgInformationSave();
		}
		// //刷新
		// if(requestCode==Resh && resultCode==PicturePreviewActivity.REFRESH)
		// {
		// if(photoid==null)
		// {
		// photoid = getIntent().getStringExtra("photoid");
		// photoIdToInfo(photoid);
		// }
		//
		// }

	}

	private View Back_Buju() {
		View view = null;
		LayoutInflater inflater = LayoutInflater.from(UpPicturesActivity.this);
		view = inflater.inflate(R.layout.recordlistclub_is_add_club, null);
		Button record_linear_add_club = (Button) view
				.findViewById(R.id.record_linear_add_club);
		Button record_linear_quxiao = (Button) view
				.findViewById(R.id.record_linear_quxiao);

		TextView infos = (TextView) view.findViewById(R.id.infos);
		infos.setText(getResources().getString(R.string.l_xb148));
		record_linear_add_club.setOnClickListener(new OnClickListener() {
			@Override
			public void onClick(View arg0) {
				// TODO Auto-generated method stub
				// Toast.makeText(getApplicationContext(), "加入", 0).show();
				if (is_apply.equals("0")) {
					Add_club("0", "");
				} else {
					Intent intent = new Intent(UpPicturesActivity.this,
							AddApplyFormActivity.class);
					intent.putExtra("pan", "set");
					intent.putExtra("cid", cid);
					startActivity(intent);
				}
				builder.dismiss();
			}
		});
		record_linear_quxiao.setOnClickListener(new OnClickListener() {

			@Override
			public void onClick(View arg0) {
				// TODO Auto-generated method stub
				// Toast.makeText(getApplicationContext(), "取消", 0).show();
				builder.dismiss();
			}
		});
		return view;
	}

	private void imgInformationSave() {
		// Utils.showPrgress(UpPicturesActivity.this);
		MyThreadTool.fixedThreadPool.execute(new Runnable() {

			@Override
			public void run() {
				Map<String, Object> map = new HashMap<String, Object>();
				map.put("type", type_upimg);
				if (cid != null) {
					map.put("cid", cid);
				} else {
					map.put("cid", "0");
				}
				if (!StringUtil.isNullOrEmpty(activity_id)) {
					map.put("activity_id", activity_id);
				} else {
					map.put("activity_id", 0);
				}
				map.put("record_id", 0);
				map.put("record_article_id", 0);
				map.put("zhan_num", 0);
				try {
					map.put("img", fengzhuang_upimginfo());
				} catch (JSONException e) {
					e.printStackTrace();
				}
				System.out.println("上传图片发送参数是:" + map.toString());
				String content = Utils.sendRequest(map, Constants.BadiUrl_1
						+ "photo/imgInformationSave");
				if (content != null) {
					resultsss = Utils.checkResult_NNN(getApplicationContext(),
							content);
					System.out.println("保存图片返回的结果是:" + content + " "
							+ resultsss.getRetmsg());
					if (resultsss != null && !resultsss.equals("null")
							&& resultsss.isRet()) {
						// mHandler.sendEmptyMessage(3);
						mhandler.sendEmptyMessageDelayed(3, 900);
					} else {
						mHandler.sendEmptyMessage(4);
					}
				} else {
					mHandler.sendEmptyMessage(2);
				}
			}
		});
	}

	private void Add_club(final String is_apply, final String content) {
		Utils.showPrgress(UpPicturesActivity.this);
		MyThreadTool.fixedThreadPool.execute(new Runnable() {
			@Override
			public void run() {
				Map<String, Object> map = new HashMap<String, Object>();
				map.put("uid", Utils.getUid(UpPicturesActivity.this));
				map.put("cid", cid);
				map.put("is_apply", is_apply);
				if (is_apply.equals("1")) {
					map.put("contents", content);
				}
				String content = Utils.sendRequest(map, Constants.BadiUrl_1
						+ "club/attendClub");
				if (content != null) {
					resultsdd = Utils.checkResult_NNN(getApplicationContext(),
							content);
					// System.out.println("加入俱乐部返回的参数是:" + content + " "
					// + resultsdd.getRetmsg());
					if (resultsdd != null
							&& !resultsdd.getRetmsg().equals("null")) {
						mHandler.sendEmptyMessage(5);
					} else {
						mHandler.sendEmptyMessage(6);
					}
				} else {
					mHandler.sendEmptyMessage(7);
				}
			}
		});
	}

	private JSONObject fengzhuang_upimginfo() throws JSONException {
		JSONObject object = new JSONObject();
		String s = "";
		if (imageAttribute.getService_img_address() != null
				&& !imageAttribute.getService_img_address().isEmpty()) {
			for (int i = 0; i < imageAttribute.getService_img_address().size(); i++) {
				s += imageAttribute.getService_img_address().get(i).toString();
			}
			// System.out.println("______上传的图片地址是:" + s);
			object.put("path", s);
		}
		object.put("photoId", imageAttribute.getXiangceid());
		object.put("uid", Utils.getUid(UpPicturesActivity.this));
		object.put("title", getResources().getString(R.string.l_xb149));
		object.put("info", imageAttribute.getInfo());
		object.put("address", imageAttribute.getAbsolute_address());
		object.put("map_x", imageAttribute.getAddress_weidu());
		object.put("map_y", imageAttribute.getAddress_jingdu());
		object.put("participator", imageAttribute.getCanyu_persons());
		String t = "";
		if (imageAttribute.getBiaoqian_map() != null
				&& !imageAttribute.getBiaoqian_map().isEmpty()) {
			// System.out.println("数" + imageAttribute.getBiaoqian_num());
			for (int j = 0; j < imageAttribute.getBiaoqian_num(); j++) {
				if (imageAttribute.getBiaoqian_map().get(j) != null) {
					t += imageAttribute.getBiaoqian_map().get(j) + ",";
				}
			}
			object.put("typeid", quchu_zuihou(t));
		}
		object.put("attachment", imageAttribute.getLaiyuan());
		object.put("is_show", imageAttribute.getIs_displaydongtai());
		return object;
	}

	private String quchu_zuihou(String s) {
		return s.substring(0, s.length() - 1);
	}

	// TODO Auto-generated method stub
	@SuppressLint("ValidFragment")
	public class UpPicturesFragment0 extends Fragment implements
			OnHeaderRefreshListener, OnFooterRefreshListener {
		private PullToRefreshView mPullToRefreshView;
		private GridView gv;
		private UpPicturesFragment0Adapter adapter;
		private Results results;
		private int Page;
		private boolean judge;
		private Message message;
		private Bundle bundle;
		private int num = 15;
		private AllPhoto_Model allPhoto_Model;
		private List<BrowseAllPhoto_Model> allPhoto_Models;
		private Handler handler = new Handler() {
			@Override
			public void handleMessage(Message msg) {
				switch (msg.what) {
				case 1:
					Utils.ExitPrgress(UpPicturesActivity.this);
					try {
						Utils.showMessage(UpPicturesActivity.this,
								getResources().getString(R.string.l_net_error));
						mPullToRefreshView.onFooterRefreshComplete();
						mPullToRefreshView.onHeaderRefreshComplete();
					} catch (Exception e) {
						// TODO: handle exception
					}

					break;
				case 2:
					Utils.ExitPrgress(UpPicturesActivity.this);
					try {
						activity_id = allPhoto_Model.getActivity_id();
						allPhoto_Models.addAll(allPhoto_Model.getShowImg());
						adapter.notifyDataSetChanged();
						if (judge) {
							if (num >= Integer.valueOf(allPhoto_Model
									.getImgNum())) {
								if (Page > 1) {
									--Page;
								} else {
									Page = 1;
								}
								num = 0;
							} else {

							}
							message = new Message();
							bundle = new Bundle();
							message.what = 1;
							bundle.putString("tital",
									"(" + allPhoto_Model.getImgNum() + ")");
							message.setData(bundle);
							mHandler.sendMessage(message);
							judge = false;
						}
						mPullToRefreshView.onFooterRefreshComplete();
						mPullToRefreshView.onHeaderRefreshComplete();
					} catch (Exception e) {
						// TODO: handle exception
					}

					break;
				case 3:
					Utils.ExitPrgress(UpPicturesActivity.this);
					try {
						Utils.showMessage(UpPicturesActivity.this,
								getResources().getString(R.string.l_xa10));
						mPullToRefreshView.onFooterRefreshComplete();
						mPullToRefreshView.onHeaderRefreshComplete();
					} catch (Exception e) {
						// TODO: handle exception
					}

					break;
				default:
					break;
				}
			}
		};

		@Override
		public void onCreate(Bundle savedInstanceState) {
			super.onCreate(savedInstanceState);
		}

		@Override
		public void onDestroy() {
			super.onDestroy();
			ImageLoader.getInstance().clearDiscCache();
			ImageLoader.getInstance().clearMemoryCache();
			System.out.println("图片清楚");
		}

		@Override
		public View onCreateView(LayoutInflater inflater, ViewGroup container,
				Bundle savedInstanceState) {
			View view = inflater.inflate(R.layout.xgridview_1, null);
			mPullToRefreshView = (PullToRefreshView) view
					.findViewById(R.id.main_pull_refresh_view);
			gv = (GridView) view.findViewById(R.id.xgridView11);
			Page = 1;
			allPhoto_Models = new ArrayList<BrowseAllPhoto_Model>();
			// gv.setXGridViewListener(this);
			adapter = new UpPicturesFragment0Adapter(allPhoto_Models);
			gv.setNumColumns(3);
			gv.setHorizontalSpacing(5);
			gv.setVerticalSpacing(5);
			judge = true;
			gv.setAdapter(adapter);
			gv.setOnItemClickListener(new OnItemClickListener() {
				@Override
				public void onItemClick(AdapterView<?> arg0, View arg1,
						int arg2, long arg3) {
					Intent intent = new Intent(UpPicturesActivity.this,
							PicturePreviewActivity.class);
					intent.putExtra("picture_list",
							(Serializable) allPhoto_Models);
					intent.putExtra("picture_postion", arg2);
					startActivityForResult(intent, Resh);
				}
			});
			mPullToRefreshView.setOnHeaderRefreshListener(this);
			mPullToRefreshView.setOnFooterRefreshListener(this);
			showImg(photoid, Page, num);
			return view;
		}

		public void gengxin() {
			// Log.v("sss1", "开始更新数据");
			Page = 1;
			allPhoto_Models.clear();
			showImg(photoid, Page, num);
		}

		// TODO Auto-generated method stub
		private void showImg(final String photoId, final int page, final int num) {
			// Utils.showPrgress(RigionPictureActivity.this);
			MyThreadTool.fixedThreadPool.execute(new Runnable() {
				@Override
				public void run() {
					String content = Utils
							.getRequest(com.badibadi.mytools.Constants.BadiUrl_1
									+ "photo/showImg?photoId="
									+ photoId
									+ "&page="
									+ page
									+ "&showNum="
									+ num
									+ "&showType=" + showType);
					// System.out.println(com.badibadi.mytools.Constants.BadiUrl_1
					// + "photo/showImg?photoId=" + photoId + "&page="
					// + page + "&showNum=" + num);
					Log.v("sss1", com.badibadi.mytools.Constants.BadiUrl_1
							+ "photo/showImg?photoId=" + photoId + "&page="
							+ page + "&showNum=" + num);
					if (content != null) {
						results = Utils.checkResult_NNN(
								getApplicationContext(), content);
						// System.out.println("查看图片:" + content);
						Log.v("sss1", "查看图片:" + content);
						// LogUtils.d("获取的图片是：————》" + results.toString());
						if (results != null
								&& !results.getRetmsg().equals("null")
								&& results.isRet()) {
							// LogUtils.d("" + results.getRetmsg());
							allPhoto_Model = new AllPhoto_Model();
							try {
								allPhoto_Model = JSONUtils
										.getEntityByJsonString(
												results.getRetmsg(),
												AllPhoto_Model.class);

								handler.sendEmptyMessage(2);
							} catch (Exception e) {
								e.printStackTrace();
							}
						} else {
							if (Page > 1) {
								--Page;
							} else {
								Page = 1;
							}
							handler.sendEmptyMessage(3);
						}
					} else {
						if (Page > 1) {
							--Page;
						} else {
							Page = 1;
						}
						handler.sendEmptyMessage(1);
					}
				}
			});
		}

		class UpPicturesFragment0Adapter extends BaseAdapter {
			// private DisplayImageOptions options;

			public UpPicturesFragment0Adapter(
					List<BrowseAllPhoto_Model> allPhoto_Models) {
				// options = new DisplayImageOptions.Builder()
				// .showStubImage(R.drawable.ic_stub)
				// .showImageForEmptyUri(R.drawable.noimage)
				// .showImageOnFail(R.drawable.noimage).cacheInMemory()
				// .cacheOnDisc().displayer(new RoundedBitmapDisplayer(5))
				// .build();
			}

			@Override
			public int getCount() {
				return allPhoto_Models.size();
			}

			@Override
			public Object getItem(int position) {
				return allPhoto_Models.get(position);
			}

			@Override
			public long getItemId(int position) {
				return position;
			}

			@Override
			public View getView(int position, View convertView, ViewGroup parent) {
				LayoutInflater inflater = LayoutInflater.from(getActivity());
				convertView = inflater.inflate(
						R.layout.rigion_prcture_gridview_item, null);
				ImageView rigion_prcture_gridview_img = (ImageView) convertView
						.findViewById(R.id.rigion_prcture_gridview_img);
				// ImageLoader.getInstance().displayImage(
				// com.badibadi.mytools.Constants.BadiDownImgUrl
				// + allPhoto_Models.get(position).getPath()
				// + Constants.App9block,
				// rigion_prcture_gridview_img, options);

				new BitmapHelp().displayImage(UpPicturesActivity.this,
						rigion_prcture_gridview_img,
						com.badibadi.mytools.Constants.BadiDownImgUrl
								+ allPhoto_Models.get(position).getPath()
								+ Constants.App9block);

				// System.out.println("图片显示路径是:"
				// + allPhoto_Models.get(position).getPath());
				return convertView;
			}

		}

		@Override
		public void onFooterRefresh(PullToRefreshView view) {
			showImg(photoid, ++Page, num);
		}

		@Override
		public void onHeaderRefresh(PullToRefreshView view) {
			// Page = 1;
			// allPhoto_Models.clear();
			// showImg(photoid, Page, num);
			gengxin();
		}

	}

	// 图标
	// TODO Auto-generated method stub
	// TODO Auto-generated method stub
	// TODO Auto-generated method stub
	// TODO Auto-generated method stub
	@SuppressLint("ValidFragment")
	public class UpPicturesFragment1 extends Fragment implements
			OnClickListener, LocationSource, AMapLocationListener,
			OnGeocodeSearchListener, OnMapClickListener, OnMarkerClickListener,
			OnInfoWindowClickListener, InfoWindowAdapter {
		protected static final String TAG = "UpPicturesFragment1";
		// 下面是地图的
		private AMap aMap;
		private MapView mapView;
		private OnLocationChangedListener mListener;
		private LocationManagerProxy mAMapLocationManager;
		private GeoPoint geoPoint;
		private boolean isFirstCallBack = true;// 是否为第一次回调

		// 发源地

		private ProgressDialog progDialog = null;
		private GeocodeSearch geocoderSearch;
		private Marker geoMarker;
		private Marker regeoMarker;

		// 这里保存要上传的地址名
		private String addressName;
		// 这里保存要上传的经纬度
		private LatLonPoint latLonPoint = new LatLonPoint(40.003662, 116.465271);
		// 网上数据的
		private Results results;
		// 每页的数量
		private int num = 99999;
		private AllPhoto_Model allPhoto_Model;
		// private List<BrowseAllPhoto_Model> allPhoto_Models;
		private int Page;
		private Handler handler = new Handler() {
			@Override
			public void handleMessage(Message msg) {
				switch (msg.what) {
				case 1:
					Utils.ExitPrgress(UpPicturesActivity.this);
					try {
						Utils.showMessage(getActivity(), getResources()
								.getString(R.string.l_net_error));
					} catch (Exception e) {
					}

					break;
				case 2:
					Utils.ExitPrgress(UpPicturesActivity.this);
					try {
						setUpMap();
					} catch (Exception e) {

					}
					break;
				case 3:
					Utils.ExitPrgress(UpPicturesActivity.this);
					try {
						Utils.showMessage(getActivity(), getResources()
								.getString(R.string.SystemError));
					} catch (Exception e) {

					}

					break;
				default:
					break;
				}
			}
		};

		@Override
		public void onCreate(Bundle savedInstanceState) {

			super.onCreate(savedInstanceState);

			showImgMap(photoid, 1, num);
		}

		@Override
		public View onCreateView(LayoutInflater inflater, ViewGroup container,
				Bundle savedInstanceState) {

			View view = inflater.inflate(R.layout.fragment_uppictures_1, null);
			mapView = (MapView) view.findViewById(R.id.map);
			mapView.onCreate(savedInstanceState);// 此方法必须重写

			initMapView();
			return view;
		}

		private void initMapView() {
			if (aMap == null) {
				aMap = mapView.getMap();
				aMap.setInfoWindowAdapter(this);// 设置自定义InfoWindow样式
				aMap.setOnMarkerClickListener(this);// 设置点击marker事件监听器
				// setUpMap();

			}

		}

		private void setUpMap() {
			aMap.moveCamera(CameraUpdateFactory.newLatLngZoom(
					Constants.CHENGDU, 12));// 设置指定的可视区域地图

			// aMap.setMyLocationStyle(myLocationStyle);
			aMap.getUiSettings().setMyLocationButtonEnabled(true);// 设置默认定位按钮是否显示
			aMap.setMyLocationEnabled(true);// 设置为true表示显示定位层并可触发定位，false表示隐藏定位层并不可触发定位，默认是false

			if (allPhoto_Model != null) {
				for (int i = 0; i < allPhoto_Model.getShowImg().size(); i++) {
					// 添加图标
					if (allPhoto_Model.getShowImg().get(i).getMap_x() != null
							&& allPhoto_Model.getShowImg().get(i).getMap_y() != null) {

						LatLng latlng = new LatLng(
								Double.parseDouble(allPhoto_Model.getShowImg()
										.get(i).getMap_x()),
								Double.parseDouble(allPhoto_Model.getShowImg()
										.get(i).getMap_y()));
						AMapUtils.drawMarker(aMap, "" + i, "", latlng);
						if (i == 0) {
							AMapUtils.CameraMoveTo(aMap, latlng);
						}
						// // 画线
						// if (i > 0) {
						// LatLng FromLaLng = new LatLng(
						// Double.parseDouble(allPhoto_Model
						// .getShowImg().get(i - 1).getMap_x()),
						// Double.parseDouble(allPhoto_Model
						// .getShowImg().get(i - 1).getMap_y()));
						// LatLng ToLaLng = new LatLng(
						// Double.parseDouble(allPhoto_Model
						// .getShowImg().get(i).getMap_x()),
						// Double.parseDouble(allPhoto_Model
						// .getShowImg().get(i).getMap_y()));
						// AMapUtils.drawLine(aMap, FromLaLng, ToLaLng,
						// Color.BLUE);
						// }

					}

				}
			}

		}

		/**
		 * 方法必须重写
		 */
		@Override
		public void onResume() {
			super.onResume();
			mapView.onResume();
		}

		/**
		 * 方法必须重写
		 */
		@Override
		public void onPause() {
			super.onPause();
			mapView.onPause();
			ImageLoader.getInstance().clearDiscCache();
			ImageLoader.getInstance().clearMemoryCache();
			System.out.println("onPause");
			deactivate();
		}

		/**
		 * 方法必须重写
		 */
		@Override
		public void onSaveInstanceState(Bundle outState) {
			super.onSaveInstanceState(outState);
			mapView.onSaveInstanceState(outState);
		}

		/**
		 * 方法必须重写
		 */
		@Override
		public void onDestroy() {
			super.onDestroy();
			ImageLoader.getInstance().clearDiscCache();
			ImageLoader.getInstance().clearMemoryCache();
			mapView.onDestroy();
			System.out.println("onDestroy图标");
		}

		@Override
		public void onLocationChanged(Location location) {
		}

		@Override
		public void onProviderDisabled(String provider) {

		}

		@Override
		public void onProviderEnabled(String provider) {

		}

		@Override
		public void onStatusChanged(String provider, int status, Bundle extras) {

		}

		// 点击地图的上东西后回调
		@Override
		public void onMapClick(LatLng latlng) {
			if (aMap != null && latlng != null) {
				aMap.clear();
				// MarkerOptions markerOptions=new MarkerOptions();
				// markerOptions.

				geoMarker = aMap
						.addMarker(new MarkerOptions()
								.anchor(0.5f, 0.5f)
								.icon(BitmapDescriptorFactory
										.defaultMarker(BitmapDescriptorFactory.HUE_BLUE)));
				// aMap.addMarker(new MarkerOptions());
				geoMarker.setPosition(latlng);
				getAddress(AMapUtil.convertToLatLonPoint(latlng));
				aMap.invalidate();
				latLonPoint = AMapUtil.convertToLatLonPoint(latlng);
				// Log.v("aaa",
				// "address+====>" + addressName + " latLonPoint--->"
				// + latLonPoint.getLatitude() + ","
				// + latLonPoint.getLongitude());

			}
		}

		/**
		 * 地理编码查询回调
		 */
		@Override
		public void onGeocodeSearched(GeocodeResult result, int rCode) {

			dismissDialog();
			if (rCode == 0) {
				if (result != null && result.getGeocodeAddressList() != null
						&& result.getGeocodeAddressList().size() > 0) {
					GeocodeAddress address = result.getGeocodeAddressList()
							.get(0);
					aMap.animateCamera(CameraUpdateFactory.newLatLngZoom(
							AMapUtil.convertToLatLng(address.getLatLonPoint()),
							15));
					geoMarker.setPosition(AMapUtil.convertToLatLng(address
							.getLatLonPoint()));
					addressName = getResources().getString(R.string.l_xb97)
							+ address.getLatLonPoint() + "\n"
							+ getResources().getString(R.string.l_xb98)
							+ address.getFormatAddress();
					// 这里保存要上传的经纬度
					latLonPoint = address.getLatLonPoint();
					// Log.v("aaa", "latLonPoint+++>" +
					// latLonPoint.getLatitude()
					// + "///" + latLonPoint.getLongitude());

					ShowToast(getActivity(), addressName);
				} else {
					ToastUtil.show(getActivity(), R.string.no_result);
				}

			} else if (rCode == 27) {
				ToastUtil.show(getActivity(), R.string.error_network);
			} else if (rCode == 32) {
				ToastUtil.show(getActivity(), R.string.error_key);
			} else {
				ToastUtil.show(getActivity(), getString(R.string.error_other)
						+ rCode);
			}
		}

		// /**
		// * 逆地理编码回调
		// */
		@Override
		public void onRegeocodeSearched(RegeocodeResult result, int rCode) {
			dismissDialog();
			if (rCode == 0) {
				if (result != null
						&& result.getRegeocodeAddress() != null
						&& result.getRegeocodeAddress().getFormatAddress() != null) {
					addressName = result.getRegeocodeAddress()
							.getFormatAddress()
							+ getResources().getString(R.string.l_xb99);
					// if(addressName!="" &&
					// searchText.getText().toString().trim()!="")
					// {
					// searchText.setText(""+result.getRegeocodeAddress().getFormatAddress());
					// }
					// aMap.animateCamera(CameraUpdateFactory.newLatLngZoom(
					// AMapUtil.convertToLatLng(latLonPoint), 15));
					regeoMarker.setPosition(AMapUtil
							.convertToLatLng(latLonPoint));
					ToastUtil.show(getActivity(), addressName);
				} else {
					ToastUtil.show(getActivity(), R.string.no_result);
				}
			} else if (rCode == 27) {
				ToastUtil.show(getActivity(), R.string.error_network);
			} else if (rCode == 32) {
				ToastUtil.show(getActivity(), R.string.error_key);
			} else {
				ToastUtil.show(getActivity(), getString(R.string.error_other)
						+ rCode);
			}
		}

		/**
		 * 隐藏进度条对话框
		 */
		public void dismissDialog() {
			if (progDialog != null) {
				progDialog.dismiss();
			}
		}

		/**
		 * 定位成功后回调函数
		 */
		@Override
		public void onLocationChanged(AMapLocation aLocation) {
			// Log.v("aaa","aLocation.getLatitude()-->");
			if (mListener != null && aLocation != null) {

				// Log.v("aaa",
				// "aLocation.getLatitude()--->"+aLocation.getLatitude()+"  aLocation.getLongitude()===>"+aLocation.getLongitude());
				mListener.onLocationChanged(aLocation);// 显示系统小蓝点

				// geoPoint=new GeoPoint((int) (aLocation.getLatitude() * 1E6),
				// (int) (aLocation.getLongitude() * 1E6));
				// //用给定的经纬度构造一个GeoPoint，单位是微度 (度 * 1E6)
				// CameraUpdateFactory a=CameraUpdateFactory.newLatLngZoom(new
				// LatLng(arg0, arg1), arg1)

				if (isFirstCallBack == true) {
					aMap.moveCamera(CameraUpdateFactory.newLatLngZoom(
							new LatLng(aLocation.getLatitude(), aLocation
									.getLongitude()), 12));// 设置指定的可视区域地图
					isFirstCallBack = false;
					latLonPoint = new LatLonPoint(aLocation.getLatitude(),
							aLocation.getLongitude());
					getAddress(new LatLonPoint(aLocation.getLatitude(),
							aLocation.getLongitude()));
				}
			}
		}

		/**
		 * 个人+俱乐部--浏览某个相册的所有图片------get
		 * 
		 * @param $photoId
		 *            //（必需）要查看的相册id
		 * @param $showType
		 *            ----（必需）查询模式：'img':图片模式(默认)，'map':图标模式
		 * @param $page
		 *            ;//第几页
		 * @param $showNum
		 *            ;//每页显示的数量
		 */
		private void showImgMap(final String photoId, final int page,
				final int num) {
			// Utils.showPrgress(RigionPictureActivity.this);
			MyThreadTool.fixedThreadPool.execute(new Runnable() {
				@Override
				public void run() {
					String content = Utils
							.getRequest(com.badibadi.mytools.Constants.BadiUrl_1
									+ "photo/showImg?photoId="
									+ photoId
									+ "&showType="
									+ "map"
									+ "&page="
									+ page
									+ "&showNum=" + num);
					// System.out.println(com.badibadi.mytools.Constants.BadiUrl_1
					// + "photo/showImg?photoId=" + photoId + "&showType="
					// + "map" + "&page=" + page + "&showNum=" + num);
					// 这里已经被标记
					if (content != null) {
						results = Utils.checkResult_NNN(
								getApplicationContext(), content);
						// Log.v(TAG, "查看图片:" + content);
						if (results != null
								&& !results.getRetmsg().equals("null")
								&& results.isRet()) {
							allPhoto_Model = new AllPhoto_Model();
							try {
								allPhoto_Model = JSONUtils
										.getEntityByJsonString(
												results.getRetmsg(),
												AllPhoto_Model.class);
								handler.sendEmptyMessage(2);
							} catch (Exception e) {
								e.printStackTrace();
							}
						} else {

							handler.sendEmptyMessage(3);
						}
					} else {

						handler.sendEmptyMessage(1);
					}
				}
			});
		}

		/**
		 * 激活定位
		 */
		@Override
		public void activate(OnLocationChangedListener listener) {
			mListener = listener;
			if (mAMapLocationManager == null) {
				mAMapLocationManager = LocationManagerProxy
						.getInstance(getActivity());
				/*
				 * mAMapLocManager.setGpsEnable(false);
				 * 1.0.2版本新增方法，设置true表示混合定位中包含gps定位，false表示纯网络定位，默认是true
				 * Location API定位采用GPS和网络混合定位方式
				 * ，第一个参数是定位provider，第二个参数时间最短是2000毫秒，第三个参数距离间隔单位是米，第四个参数是定位监听者
				 */
				mAMapLocationManager.requestLocationUpdates(
						LocationProviderProxy.AMapNetwork, 2000, 10, this);
			}
		}

		/**
		 * 停止定位
		 */
		@Override
		public void deactivate() {
			mListener = null;
			if (mAMapLocationManager != null) {
				mAMapLocationManager.removeUpdates(this);
				mAMapLocationManager.destory();
			}
			mAMapLocationManager = null;
		}

		/**
		 * 显示进度条对话框
		 */
		public void showDialog() {
			progDialog.setProgressStyle(ProgressDialog.STYLE_SPINNER);
			progDialog.setIndeterminate(false);
			progDialog.setCancelable(true);
			progDialog.setMessage(getResources().getString(R.string.l_xb63));
			progDialog.show();
		}

		/**
		 * 响应逆地理编码
		 */
		public void getAddress(final LatLonPoint latLonPoint) {
			showDialog();
			RegeocodeQuery query = new RegeocodeQuery(latLonPoint, 200,
					GeocodeSearch.AMAP);// 第一个参数表示一个Latlng，第二参数表示范围多少米，第三个参数表示是火系坐标系还是GPS原生坐标系
			geocoderSearch.getFromLocationAsyn(query);// 设置同步逆地理编码请求
		}

		/**
		 * 响应地理编码
		 */
		public void getLatlon(final String name) {
			showDialog();
			GeocodeQuery query = new GeocodeQuery(name, null);// 第一个参数表示地址，第二个参数表示查询城市，中文或者中文全拼，citycode、adcode，
			geocoderSearch.getFromLocationNameAsyn(query);// 设置同步地理编码请求
		}

		@Override
		public void onClick(View v) {

		}

		@Override
		public View getInfoContents(Marker arg0) {
			// TODO Auto-generated method stub
			return null;
		}

		/**
		 * 监听自定义infowindow窗口的infowindow事件回调
		 */
		@Override
		public View getInfoWindow(Marker marker) {
			// TODO Auto-generated method stub
			View infoWindow = getActivity().getLayoutInflater().inflate(
					R.layout.custom_info_window, null);

			render(marker, infoWindow);
			return infoWindow;
		}

		private void render(Marker marker, View view) {
			// TODO Auto-generated method stub
			ImageView img = (ImageView) view.findViewById(R.id.img);
			String p = marker.getTitle();
			// Log.i(TAG, "position==>" + p);
			int pos = Integer.parseInt(marker.getTitle().toString());
			try {
				// VolleyTools.displayImageByNetworkImageView(getActivity(),
				// Constants.BadiDownImgUrl
				// + "/"
				// + allPhoto_Model.getShowImg().get(pos)
				// .getPath(), img);
				// ImageLoader.getInstance().displayImage(
				// Constants.BadiDownImgUrl
				// + "/"
				// + allPhoto_Model.getShowImg().get(pos)
				// .getPath() + Constants.App9block, img,
				// options);
				new BitmapHelp().displayImage(UpPicturesActivity.this, img,
						Constants.BadiDownImgUrl
								+ "/"
								+ allPhoto_Model.getShowImg().get(pos)
										.getPath() + Constants.App9block);
			} catch (Exception e) {
				// TODO: handle exception
			}
			// 数量
			TextView imgNum = (TextView) view.findViewById(R.id.imgNum);
			imgNum.setText("");
			// 地址
			TextView address = (TextView) view.findViewById(R.id.address);
			address.setText(""
					+ allPhoto_Model.getShowImg().get(pos).getAddress());
			// 内容
			TextView info = (TextView) view.findViewById(R.id.info);
			info.setText("" + allPhoto_Model.getShowImg().get(pos).getInfo());
			// 标题
			TextView title = (TextView) view.findViewById(R.id.title);
			title.setText("" + allPhoto_Model.getShowImg().get(pos).getTitle());
			// String title = marker.getTitle();
			// TextView titleUi = ((TextView) view.findViewById(R.id.title));
			// if (title != null) {
			// SpannableString titleText = new SpannableString(title);
			// titleText.setSpan(new ForegroundColorSpan(Color.RED), 0,
			// titleText.length(), 0);
			// titleUi.setTextSize(15);
			// titleUi.setText(titleText);
			//
			// } else {
			// titleUi.setText("");
			// }
		}

		@Override
		public void onInfoWindowClick(Marker arg0) {
			// TODO Auto-generated method stub

		}

		@Override
		public boolean onMarkerClick(Marker arg0) {
			// TODO Auto-generated method stub
			return false;
		}
	}
}
